<template>
  <el-dialog title="名单导入"
             :close-on-click-modal="false"
             :visible.sync="dialogShow"
             width="400px"
             :before-close="handleClose">
    <el-upload ref="upload"
               :auto-upload="false"
               :before-upload="beforeUpload"
               :on-success="successUploadCallback"
               :on-remove="remove"
               :file-list="fileList"
               :limit="1"
               :on-exceed="exceed"
               accept=".xls,.xlsx"
               class="upload-demo"
               drag
               :action="target">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      <div class="el-upload__tip"
           slot="tip">只能上传excel文件</div>
    </el-upload>
    <span slot="footer"
          class="dialog-footer">
      <el-button @click="handleClose"
                 size="small">取 消</el-button>
      <el-button type="primary"
                 @click="sure"
                 size="small">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  props: {
    target: String,
    dialogShow: Boolean,
    handleClose: Function,
    beforeUpload: Function,
    successUploadCallback: Function,
    remove: Function,
    fileList: Array
  },
  methods: {
    exceed () {
      this.$message.error('只能上传一个文件')
    },
    sure () {
      this.$refs.upload.submit()
    }
  }
}
</script>
